package config

import (
	"fmt"
	"time"
)

type app struct {
	Name            string        `ini:"name"`
	Port            string        `ini:"port"`
	Host            string        `ini:"host"`
	WriteTimeout    time.Duration `ini:"write_timeout"`
	ReadTimeout     time.Duration `ini:"read_timeout"`
	Env             string        `ini:"env"`
	ISCron          bool          `ini:"is_cron"`
	TimeFormat      string        `ini:"time_format"`
	LogSavePath     string        `ini:"log_save_path"`
	LogSaveName     string        `ini:"log_save_name"`
	LogFileExt      string        `ini:"log_file_ext"`
	RuntimeRootPath string        `ini:"runtime_root_path"`
	PprofPort       int           `ini:"pprof_port"`
	ProduceEnv      string        `ini:"product_env"`
	TargetUrl       string        `ini:"target_url"`
	Development     string        `ini:"development"`
	Concurrency     int           `ini:"concurrency"`
	NatsUrl         string        `ini:"nats_url"`
	MaxMachines     int           `ini:"max_machines"`
}

func (a *app) Address() string {
	return fmt.Sprintf("%s:%s", a.Host, a.Port)
}

type redisConfig struct {
	RedisServer   string        `ini:"redis_server"`
	RedisPassword string        `ini:"redis_password"`
	RedisDb       int           `ini:"redis_db"`
	MaxRetries    int           `ini:"max_retries"`
	IdleTimeout   time.Duration `ini:"idle_timeout"`
}

type database struct {
	Type            string `ini:"type"`
	Host            string `ini:"host"`
	Port            int    `ini:"port"`
	User            string `ini:"user"`
	Password        string `ini:"password"`
	DbName          string `ini:"table_name"`
	MaxIdleConnects int    `ini:"max_idle_connects"`
	MaxOpenConnects int    `ini:"max_open_connects"`
}

type clickHouseBase struct {
	Host               string `ini:"host"`
	Port               int    `ini:"port"`
	DBName             string `ini:"table_name"`
	User               string `ini:"user"`
	Password           string `ini:"password"`
	ReadTimeout        int    `ini:"read_timeout"`
	WriteTimeout       int    `ini:"write_timeout"`
	MinIdleConns       int    `ini:"min_idle_conns"`
	MaxOpenConns       int    `ini:"max_open_conns"`
	MaxLifetimeSeconds int    `ini:"max_lifetime_seconds"`
}
